﻿TokenDeclarator:
    Literal (value : QuoteLiteral, name : Identifier?)
    Named (name : Identifier, text : StringLiteral?)

TokenDeclarationKind: one of
    Token
    EndMarker Indent Unindent NewLine Layout Hidden
    Keyword Reserved Contextual

TokenDeclaration = (
    kind : TokenDeclarationKind,
    items : [TokenDeclarator]+,
    `type` : TypeExpression?,
)

SyntacticToken:
    Literal (value : QuoteLiteral)
    Named (name : Identifier)

OperatorDeclarationKind: one of
    Left Right Nonassociative
    Shift Reduce

OperatorDeclaration = (
    kind : OperatorDeclarationKind,
    items : [SyntacticToken]+,
)

GoalDeclarator = (name : Identifier, endMarkers : [SyntacticToken])
GoalDeclaration = (items : [GoalDeclarator]+)
StartDeclaration = (isExclusive : bool, items : [Identifier]+)

LexicalPrecedenceOperator: one of
    LessTilde LessMinus MinusTilde
    LessLess LessS
    MinusLess MinusS

LexicalPrecedenceDeclarator = (
    left : SyntacticToken,
    op : LexicalPrecedenceOperator,
    right : SyntacticToken,
)

LexicalPrecedenceDeclaration = (items : [LexicalPrecedenceDeclarator]+)

IncludeDeclarator:
    Literal (value : StringLiteral)
    Named (name : [Identifier]+)

IncludeDeclaration = (items : [IncludeDeclarator]+)
DefineDeclaration = (name : [Identifier]+, value : Expression)
ExceptionDeclaration = (items : [Identifier]+, baseName : Identifier?)
ExceptionBaseDeclaration = (name : Identifier)

SyntacticDirective:
    Token (declaration : TokenDeclaration)
    Operator (declaration : OperatorDeclaration)
    Goal (declaration : GoalDeclaration)
    Start (declaration : StartDeclaration)
    LexicalPrecedence (declaration : LexicalPrecedenceDeclaration)
    Include (declaration : IncludeDeclaration)
    Define (declaration : DefineDeclaration)
    Exception (declaration : ExceptionDeclaration)
    ExceptionBase (declaration : ExceptionBaseDeclaration)
    AutoToken
    Indented

SyntacticDirectiveDeclaration = (items : [SyntacticDirective])

SyntacticSymbol:
    Literal (value : QuoteLiteral)
    Named (name : Identifier)
    Group (branches : [SyntacticBranch]+)

SyntacticTerm:
    Symbolic (symbol : SyntacticSymbol)
    Kleene (operand : SyntacticSymbol)
    Optional (operand : SyntacticSymbol)
    Positive (operand : SyntacticSymbol)
    KleeneSequence (operand : SyntacticSymbol, separator : SyntacticSymbol)
    PositiveSequence (operand : SyntacticSymbol, separator : SyntacticSymbol)
    KleeneGroup (branches : [SyntacticBranch]+)
    OptionalGroup (branches : [SyntacticBranch]+)
    attributes! (name : Identifier?)

SyntacticBranch = (
    terms : [SyntacticTerm],
    precedence : SyntacticToken?,
    action : SemanticAction?,
    label : Identifier?,
)

SyntacticRuleDeclarator:
    Branch (branch : SyntacticBranch)
    Operator (declaration : OperatorDeclaration)

SyntacticDeclarator = (
    name : Identifier,
    `type` : TypeExpression?,
    rules : [SyntacticRuleDeclarator],
)

SyntacticDeclaration = (declarators : [SyntacticDeclarator])







%%



%%

